<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Manazra.Models.Article>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	DeleteArticles
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>DeleteArticles</h2>

    <table>
        <tr>
            <th></th>
            <th>
                RecId
            </th>
            <th>
                Author
            </th>
            <th>
                Title
            </th>            
            <th>
                Category
            </th>
            <th>
                Points
            </th>
            <th>
                CreatedDate
            </th>
            <th>
                UpdatedDate
            </th>            
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
                <%= Html.ActionLink("Delete", "DeleteArticle", new { id = item.RecId }, new { rel = "lnkDelArticle" }) %>
            </td>
            <td>
                <%= Html.Encode(item.RecId) %>
            </td>
            <td>
                <%= Html.Encode(item.Author) %>
            </td>
            <td>
                <%= Html.Encode(item.Title) %>
            </td>
            <td>
                <%= Html.Encode(item.Category.Title) %>
            </td>
            <td>
                <%= Html.Encode(item.Points) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.CreatedDate)) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.UpdatedDate)) %>
            </td>
        </tr>    
    <% } %>

    </table>
    
    <script type="text/javascript">
        $(document).ready(function() {
            $("a[rel='lnkDelArticle']").click(function(e) {
                e.preventDefault();
                var _this = $(this);
                $.getJSON(this.href, function(data) {
                    if (!data.Status) { alert(data.Message); return; }
                    _this.parent().parent().hide().remove();
                });
            });
        });
    </script>
    
</asp:Content>

